<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap core CSS -->
<link rel="stylesheet" type="text/css" href="../../bootstrap-3.3.7/dist/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="../../bootstrap-3.3.7/dist/css/bootstrap-theme.min.css" />
<link rel="stylesheet" type="text/css" href="../../css/index.css" />
<link rel="stylesheet" type="text/css" href="../../css/personal.css" />
<link rel="stylesheet" type="text/css" href="../../css/background.css" />
<link rel="stylesheet" type="text/css" href="../../css/upload/fileinput.css" />

<script type="text/javascript" src="../../bootstrap-3.3.7/dist/js/jquery.min.js"></script>
<script type="text/javascript" src="../../bootstrap-3.3.7/dist/js/bootstrap.js"></script>
<script type="text/javascript" src="../../js/upload/fileinput.js"></script>
<script type="text/javascript" src="../../js/login/jquery.form.min.js"></script>

<link rel="stylesheet" type="text/css" href="../../css/bootstrapValidator.min.css" />
<script type="text/javascript" src="../../js/bootstrapValidator.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<link href="../../bootstrap-3.3.7/docs/assets/css/ie10-viewport-bug-workaround.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
</head>
<body>
	<div class="container">
		<div class="row clearfix">
			<div class="col-md-12" style="padding-bottom: 10px">
				<%@include file="../common/header.jsp"%>
			</div>
		</div>
		<div class="row clearfix" style="height:400px">
			<div class="col-md-12">
				<h4 class="heading">忘记密码</h4>
				<div class="myline"></div>
				<form class="form-horizontal" enctype="multipart/form-data" style="padding-top: 50px" id="changeForm" method="post">
					<div class="row">
						<div class="col-md-3"></div>
						<div class="col-md-5">
						<input type='text' hidden="true" id='user_id' value="<%=request.getParameter("user_id") %>"/>
							<div class="form-group">
								<label class="col-md-3 control-label">新密码:</label>
								<div class="col-md-9">
									<input type="password" class="form-control" name="password" id="password">
								</div>
							</div>
							<div class="form-group">
								<label class="col-md-3 control-label">确认密码:</label>
								<div class="col-md-9">
									<input type="password" class="form-control" name="repassword" id="repassword">
								</div>
							</div>
							<center>
								<div class="form-group sepH_c">
									<div class="col-md-12">
										<button type="button" class="btn  btn-info" onclick="change()">确定修改</button>
									</div>
								</div>
							</center>
						</div>
					</div>
				</form>
			</div>
		</div>
		<div class="row clearfix">
			<div class="col-md-12" style="padding-bottom: 10px">
				<%@include file="../common/bottom.jsp"%>
			</div>
		</div>
	</div>
</body>
<script>
	//点击确认修改密码按钮
    function change(){
    	$('#changeForm').bootstrapValidator('validate');
    	$.ajax({
			url : "../permission/changepwd",
			type : "POST",
			dataType : "json",
			data : {
				"user_id" :$("#user_id").val(),
				"user_password":$("#password").val()
			},
			success : function(data) {
				if(data==1){
					
					window.location.href="changeok.jsp";
				}
				if(data!=1)
					alert("修改失败");
			}
		});   	
    }
	$(document).ready(function() {	
		$('#changeForm').bootstrapValidator({
			message : 'This value is not valid',
			feedbackIcons : {
				valid : 'glyphicon glyphicon-ok',
				invalid : 'glyphicon glyphicon-remove',
				validating : 'glyphicon glyphicon-refresh'
			},
			fields : {
				password : {/*键名和input name值对应*/
					message : '密码无效',
					validators : {
						notEmpty : {/*非空提示*/
							message : '密码不能为空'
						},
						regexp : {/* 只需加此键值对，包含正则表达式，和提示 */
							regexp : /^[a-zA-Z0-9_\.]+$/,
							message : '只能是数字和字母.'
						},
						stringLength : {/*长度提示*/
							min : 6,
							max : 12,
							message : '密码长度必须在6到12之间'
						}
					/*最后一个没有逗号*/
					}
				},
				repassword : {
					message : '密码无效',
					validators : {
						notEmpty : {
							message : '确认密码不能为空'
						},
						stringLength : {
							min : 6,
							max : 12,
							message : '确认密码长度必须在6到12之间'
						},
						identical : {//相同
							field : 'password',
							message : '两次密码不一致'
						},
						regexp : {//匹配规则
							regexp : /^[a-zA-Z0-9_\.]+$/,
							message : '只能是数字和字母'
						}
					}
				}
			}
		});
	});
</script>
</html>